//1.
var str = '您的姓名是{{name}},您的密码是{{password}}'
var obj = {
    name: 'yjw'
}

var reg = /\{\{\w{1,}\}\}/g
str = str.replace(reg, function (v, i) {
    console.log(i);
    var reg1 = /\W/g
    v = v.replace(reg1, '')
    for (const k in obj) {
        if (k == v) {
            return obj[k]
        } else {
            return '{{' + v + '}}'
        }
    }
})
console.log(str);

//2.
var url = 'http://baidu.com/come?wd=123&hello=789'

var query = url.split('?')[1]
var arr = query.split('&')
var obj = {}
arr.forEach(item => {
    var arr1 = item.split('=')
    obj[arr1[0]] = arr1[1]
})
console.log(obj);

//3.
//3.1
var str = 'tygfghfvyj'
var map = new Map()
for (let i in str) {
    const item = str[i]
    if (map.has(item)) {
        map.set(item, map.get(item) + 1)
    } else {
        map.set(item, 1)
    }
}

console.log(map);
//3.2
var str = 'tygfghfvyjy'
var obj = {}
var compareNum=1
var compareItem=null
for (let i = 0; i < str.length; i++) {
    var item = str[i]
    if (obj[item]) {
        var num = obj[item]
        num++
        if (num>compareNum) {
            compareNum=num
            compareItem=item
        }
        obj[item] = num
    } else {
        obj[item] = 1
    }
}

console.log(obj);
console.log(compareItem+':'+compareNum);
//3.3
var str = 'tygfghfvyj'
var obj = {}
var compareNum=1
for (let i = 0; i < str.length; i++) {
    var item = str[i]
    if (obj[item]) {
        var num = obj[item]
        num++
        if (num>compareNum) {
            compareNum=num
        }
        obj[item] = num
    } else {
        obj[item] = 1
    }
}

console.log(obj);
var arr=[]
for (const k in obj) {
    if (obj[k]==compareNum) {
        arr.push(k+':'+obj[k])
    }
}
console.log(arr);